package com.neusoft.controller;

import com.neusoft.dto.MedicalTechnologyDto;
import com.neusoft.entity.MedicalTechnology;
import com.neusoft.service.MedicalTechnologyService;
import com.neusoft.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author akemihomurasama
 */
@RestController
@RequestMapping("/medicalTechnology")
@CrossOrigin
public class MedicalTechnologyController {
    @Autowired
    private MedicalTechnologyService medicalTechnologyService;

    /**
     * 查询医技项目数量，根据分类查询
     *
     * @param techType 医技项目分类
     * @return 数量
     */
    @RequestMapping("/queryTecNum/{techType}")
    public Result queryTecNum(@PathVariable String techType) {
        return medicalTechnologyService.queryTecNum(techType);
    }

    /**
     * 根据分类查询医技项目列表
     *
     * @param techType 分类
     * @return 列表
     */
    @RequestMapping("/queryTechByType/{techType}")
    public Result queryTechByType(@PathVariable String techType) {
        return medicalTechnologyService.queryTechByType(techType);
    }

    /**
     * 根据病人id和医技项目id查询医技项目列表
     *
     * @param registerId 医技项目id列表
     * @return 医技项目列表
     */
    @RequestMapping("/queryTechList/{registerId}")
    public Result queryTechList(@PathVariable int registerId) {
        return medicalTechnologyService.queryAllTechByPatient(registerId);
    }

    /**
     * 根据患者id查询医技项目和对应的申请的状态
     *
     * @param registerId 医技项目
     * @return 查询结果
     */
    @RequestMapping("/queryTechWithState/{registerId}")
    public Result queryTechWithState(@PathVariable int registerId) {
        return medicalTechnologyService.queryTechWithState(registerId);
    }

    /**
     * 查看已缴费的申请
     * @param registerId 患者id
     * @return 结果列表
     */
    @RequestMapping("/queryPayedTech/{registerId}")
    public Result queryPayedTech(@PathVariable int registerId) {
        return medicalTechnologyService.queryPayedTech(registerId);
    }

    /**
     * 根据申请状态和患者id查询申请列表
     *
     * @param registerId 患者id
     * @param state      申请状态
     * @return 申请列表
     */
    @RequestMapping("/queryTechByStateWithRequestId/{registerId}/{state}")
    public Result queryTechByStateWithRequestId(@PathVariable int registerId, @PathVariable String state) {
        return medicalTechnologyService.queryTechByStateWithRequestId(registerId, state);
    }

    /**
     * 同时根据申请id修改申请状态为已退费
     *
     * @param medicalTechnologyDtoList 申请列表
     * @return 修改结果
     */
    @RequestMapping("/techGiveUpMoney")
    public Result techGiveUpMoney(@RequestBody List<MedicalTechnologyDto> medicalTechnologyDtoList) {
        return medicalTechnologyService.techGiveUpMoney(medicalTechnologyDtoList);
    }
}

